﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="notification_edit_form.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Notification.notification_edit_form" %>
<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <%int id = int.Parse(Request.QueryString["id"]);
      var get_notification = new TblNotificationController().FetchAll().Where(x => x.NotificationId == id).Single();
        string accept = get_notification.NotificationReceiver;
        string[] get_seen = get_notification.NotificationSeen.Split(',');
         %>
    <header class="w3-padding w3-center"><b>Sửa thông báo</b></header>
    <div class="w3-padding w3-row">
        <label class="w3-col l1">Tiêu đề</label><input class="txt_notice_title tb-text w3-col" type="text" placeholder="Nhập tiêu đề thông báo" value="<%=get_notification.NotificationTitle %>" />
    </div>
    <div class="w3-padding w3-row">
        <label class="w3-col l1">Nội dung</label><textarea id="txt_edit_notice_content" class="w3-col"><%=get_notification.NotificationContent %></textarea>
    </div>
    <div class="w3-padding w3-row">
        <label class="w3-col l1">Gửi đến</label>
        <% var get_role = new TblManagerRoleController().FetchAll(); %>
        <ul class="ss-author-list ss-checkbox w3-col l10">
            <%foreach(TblManagerRole role in get_role) {
                    var get_manager = new TblManagerController().FetchAll().Where(x => x.Role == role.RoleId && x.Active == true);
                    if (get_manager.ToList().Count == 0)
                        continue;
                    %>
            <li>
                <a class="ss-author-list-item">
                    <input class="ss-check-room" <%if (check_full_acceot(role.RoleId, accept))
                        {%>checked="checked"<%} %> type="checkbox" id="edit-notice-<%=role.RoleId %>" /><label for="edit-notice-<%=role.RoleId %>" class="ss-check"></label><i onclick="ss_open_author_list(this)" class="ss-show-member-btn fa fa-caret-right w3-large"></i><i class="ss-author-icon fa fa-users"></i><label><%=role.RoleName %></label>
                </a>
                <ul class="ss-author-list ss-author-member-list">
                    <%foreach (TblManager manager in get_manager)
                        { %>
                    <li><a>
                        <input <%if (check_accept(manager.ManagerId, accept))
                            {%>checked="checked"<%} %> class="ss-check-member" value="<%=manager.ManagerId %>" type="checkbox" id="edit-notice-manager-<%=manager.ManagerId %>" /><label for="edit-notice-manager-<%=manager.ManagerId %>" class="ss-check"></label><i class="fa fa-user"></i><span><%=manager.FullName %></span></a></li>
                    <%} %>
                </ul>
            </li>
            <%} %>
        </ul>
    </div>
    <div class="w3-padding w3-row">
        <label class="w3-col l1">Đã xem</label>
        <i  id="notification_seen_area" class="w3-col l10">
            <%foreach (string seen in get_seen)
                {
                    if (!String.IsNullOrEmpty(seen))
                    {
                        var get_admin = new TblManagerController().FetchAll().Where(x => x.ManagerId == int.Parse(seen)).Single();
                        %>
            <img src="../../../Content/avatar/<%=get_admin.Avatar %>" style="width: 25px;height: 25px;margin-bottom: 6px;transition: all 0.2s;" title="<%=get_admin.FullName %>"/>
            <%}
                         } %>
        </i>
    </div>
    <div class="w3-padding-8 w3-center">
        <a onclick="btn_save_edited(<%=get_notification.NotificationId %>)" class="w3-btn w3-teal"><i class="fa fa-save"></i>&nbsp;Lưu</a>
        <a onclick="btn_notice_resend(<%=get_notification.NotificationId %>)" class="w3-btn w3-teal"><i class="fa fa-send-o"></i>&nbsp;Gửi lại</a>
        <a onclick="btn_notice_del(<%=get_notification.NotificationId %>)" class="w3-btn w3-teal"><i class="fa fa-trash-o"></i>&nbsp;Xóa</a>
    </div>
</body>
</html>
